<% Option Explicit %>
<!--#include file="includes/cb_adovbs_sys.inc"-->
<!--#include file="includes/authority_sys.asp" -->
<!--#include file="includes/header_sys.asp"-->
<!--#include file="includes/generally_sys.asp"-->
<!--#include file="includes/translate.asp"-->
<%
on error resume next
'Codepage einstellen
Session.CodePage = 65001'Unicode, 8-bit encoding
Response.CharSet = "utf-8"
Dim  objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.open strComplete_sys
If CStr(Session("ses_iu")) <> "" And CStr(Session("ses_iu")) <> "0" Then
    dim rs, sql, resp, rs1
    dim lng_k_athlete, next_mease, arr, timezone
    timezone = Replace(Request("timezone"), " ", "+")
    lng_k_athlete = fc_lng_foreign_key(CStr(Session("ses_iu")), 4)
    next_mease = Request("next_measurement")
    arr = Split(next_mease, ".")
    next_mease = arr(2) & arr(1) & arr(0)
    set rs = Server.CreateObject("ADODB.Recordset")
    set rs1 = Server.CreateObject("ADODB.Recordset")
    sql = "select 1 from tbl_0970_reminder_schedule where lng_k_athlete = '" & lng_k_athlete & "'"
	rs.Open sql, objConn
	if not rs.EOF then
        sql = "update tbl_0970_reminder_schedule set " &_
                "time_zone = '" & timezone & "', " &_
                "first_email = '" & Request("prime_email") & "', " &_
                "diff_first_email = '" & Request("diff_first_email") & "', " &_
                "second_email = '" & Request("second_email") & "', " &_
                "diff_second_email = '" & Request("diff_second_email") & "', " &_
                "next_mease = '" & next_mease & "', " &_
                "`interval` = '" & Request("interval_plan") & "', " &_
                "days_ahead = '" & Request("remind_me") & "', " &_
                "pause = '" & Request("pause") & "'"
        rs1.Open sql, objConn
        'rs1.Close
    else
        sql = "insert into tbl_0970_reminder_schedule set " &_
                "lng_k_athlete = '" & lng_k_athlete & "', " &_
                "time_zone = '" & timezone & "', " &_
                "first_email = '" & Request("prime_email") & "', " &_
                "diff_first_email = '" & Request("diff_first_email") & "', " &_
                "second_email = '" & Request("second_email") & "', " &_
                "diff_second_email = '" & Request("diff_second_email") & "', " &_
                "next_mease = '" & next_mease & "', " &_
                "`interval` = '" & Request("interval_plan") & "', " &_
                "days_ahead = '" & Request("remind_me") & "', " &_
                "pause = '" & Request("pause") & "'"
        rs1.Open sql, objConn
        'rs1.Close
	end if
    rs.Close
    resp = "{status: 'OK', msg: '" & fc_value_string(Session("ses_i_language"), "var_remind_18") & "', iu: '" & Session("ses_iu") & "', ig: '" & Session("ses_ig") & "'}"
    'resp = "{status: 'OK', msg: '"&next_mease&"', iu: '" & Session("ses_iu") & "', ig: '" & Session("ses_ig") & "'}"
Else
    resp = "{status: 'OK', msg: '', iu: '0', ig: '0'}"
End If
If Err.Number <> 0 Then
    resp = "{status: 'error', msg: '"&Err.Description&"'}"
    Err.Clear
End If
Response.Write(resp)
'Response.Write(sql)

%>